package com.gxa.meiye.admin.shop.controller;

import com.gxa.meiye.admin.shop.service.FinanceService;
import com.gxa.meiye.core.common.JsonResult;
import com.gxa.meiye.core.common.ResponseData;
import com.gxa.meiye.core.pojo.shopManagement.Order;
import com.gxa.meiye.core.pojo.shopManagement.OrderManagement;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Author cc
 * @PackageName meiye
 * @Package com.gxa.meiye.admin.shop.controller
 * @Date 2022/7/25 8:18
 * @Version 1.0
 */
@RestController
@RequestMapping("shopFinance")
@Api(tags = "财务管理接口")
public class AdminFinanceController {
    @Autowired
    private FinanceService financeService;
    @GetMapping("checkFinanceAll")
    @ApiOperation("查询所有财务")
    public ResponseData financeCheckAll(){
        ResponseData rd = new ResponseData();
        List<Order> allFinance = financeService.getAllFinance();
        Integer total = financeService.getAllFinanceCount();
        rd.setData(allFinance);
        rd.setCode(200);
        rd.setCount(total);
        return rd;
    }



    @GetMapping("checkFinanceByCondition")
    @ApiOperation("条件查询财务状况 status 2已支付 7退款中 8对应已退款 4对应待结算 5对应已结算")
    public Map financeCheckByCondition(@RequestParam Integer pageNum,
                                       @RequestParam  Integer pageSize, Order order){
        JsonResult jsonResult = new JsonResult();
        pageNum = (pageNum-1)*pageSize;
        Integer total = financeService.conditionAll(order);
        Integer status = order.getStatus();
        String endTime = order.getEndTime();
        String startTime = order.getStartTime();
        String orderNumber = order.getOrderNumber();
        String serialNumber = order.getSerialNumber();
        List<Order> data = financeService.getByCondition(pageNum, pageSize, endTime,orderNumber, serialNumber,startTime,status);
        jsonResult.setCode("200");
        jsonResult.set("data",data);
        jsonResult.set("total",total);
        return jsonResult.getMap();
    }
}
